﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using System.Windows.Forms;
using Algorithm;
using Common;
using Logs;
using Test.TestCommunication;
using Test.TestCustomControl;
using Test.TestCusTomControl;
using Test.TestDbHelper;
using iTextSharp.text;
using iTextSharp.text.pdf;
using Serializer;
using Test.Print;
using Test.Testitextsharp;
using DbHelper.Enity;
using DbHelper;
using Test.AutoUpdater;

namespace Test {
    static class Program {
#if DEBUG
        [System.Runtime.InteropServices.DllImport("kernel32.dll")]
        private static extern bool AllocConsole();
#endif
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main() {
#if DEBUG
            AllocConsole();
#endif
            log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            #region 日志测试
            //Log.Error("error");
            #endregion
            #region 通讯测试
            //new TestSerial().Startup();
            //new TestUdp().Startup();
            //new TestTcp().Startup();
            #endregion
            #region xml操作类测试
            //XmlHelper.XmlHelper xml = new XmlHelper.XmlHelper();
            //Console.WriteLine(xml.GetAttributeValue("111"));
            #endregion
            #region Serializable and Deserialize
            //SerializerHelper serializerHelper = new SerializerHelper();
            ////创建实体类，例如：Entity entity = new Entity(...);
            //serializerHelper.Serializer(typeof (Entity),entity, FilePath);
            #endregion
            #region 通用算法测试
            //Algorithm.Common common = new Algorithm.Common();
            ////common.GetSameCount();

            //int[] a = new[] {5, 4, 6, 3, 9, 7};

            //int[] b  = common.BubbleSort(a);
            //foreach (int i in b)
            //{
            //    Console.WriteLine(i);
            //}
            #endregion
            #region itextsharp测试
            //new TestItextsharp().BtnPrint();
            #endregion
            #region MD5测试
            //MD5Helper md5 = new MD5Helper();
            //string str = md5.MD5Encryption64("1079857385123456789");
            //Console.WriteLine(str);
            #endregion
            #region DES加密解密测试
            //DESHelper des = new DESHelper();
            //string str = des.Encrypt("mchip.test","12345678");
            //Console.WriteLine("加密密码："+str);

            //Console.WriteLine("解密密码："+des.Decrypt(str,"12345678"));

            #endregion
            #region 获取硬件信息

            //foreach (var wmi in Wmi.MulGetHardwareInfo(Wmi.HardwareEnum.Win32_PnPEntity,"Name"))
            //{
            //    Console.WriteLine(wmi);
            //}
            #endregion
            #region SerializableDictionary
            ////Create SerializableDictionary
            //List<int> lis = new List<int>();
            //lis.Add(123);
            //SerializableDictionary<string,List<int>> dic = new SerializableDictionary<string,List<int>>();
            //dic.Add("TestKey",lis);

            ////Serializer to Test.xml
            //serializerHelper.Serializer(typeof(SerializableDictionary<string,List<int>>),dic,"Test.xml");
            ////Deserialize to SerializableDictionary class
            //dic = serializerHelper.Deserialize(typeof(SerializableDictionary<string,List<int>>),"Test.xml") as SerializableDictionary<string,List<int>>;
            #endregion
            #region "FullScreen test"
            //Screenshots screenshots = new Screenshots();
            //screenshots.FullScreen("FullScreen.jpg");
            #endregion
            #region 数据库测试
            //new TestMySqlHelper().Test();

            //IUser iuser = DataAccess.CreateUser();
            //iuser.GetInfoAll();

            #endregion
            #region 日志文件夹大小检查是否需要压缩
            //DirectoryInfo dirInfo = new DirectoryInfo("./Logs");
            //long len = ZipHelper.DirSize(dirInfo);
            //if(len > Math.Pow(1024,1)) {
            //    string[] filespath = ZipHelper.GetfilePaths(dirInfo);
            //    ZipHelper.Zip(filespath,string.Format("./Logs/log_file{0}.zip",DateTime.Now.ToString("yyyy-MM-dd")));
            //}
            #endregion
            #region 过期检查
            //var result = DateExprieHelper.IsExpriredByDay(new DateTime(2017,1,1),20);
            //if(result) {
            //    Console.WriteLine("已经到期了~~");
            //} else {
            //    Console.WriteLine("还没到期~~");
            //}
            #endregion
            #region 判断是否支持触摸

            //Console.WriteLine("GetSystemMetrics(SM_DIGITIZER)：" + Convert.ToString(GetSystemMetrics(SM_DIGITIZER), 16));
            //Console.WriteLine("GetSystemMetrics(SM_MAXIMUMTOUCHES)：" + GetSystemMetrics(SM_MAXIMUMTOUCHES));
            //Console.WriteLine("GetSystemMetrics(SM_TABLETPC)：" + GetSystemMetrics(SM_TABLETPC));
            //Console.WriteLine("System.Windows.SystemParameters.IsTabletPC：" + System.Windows.SystemParameters.IsTabletPC);  //需要加载PresentationFramework这个References
            //Console.WriteLine("Windows7.Multitouch.TouchHandler.DigitizerCapabilities.IsMultiTouchReady：" + Windows7.Multitouch.TouchHandler.DigitizerCapabilities.IsMultiTouchReady); //需要添加对 Windows7.Multitouch.dll 和 Windows7.Multitouch.WPF.dll 的引用

            #endregion

            #region 自动更新
            UpdateInfo updateInfo = new UpdateInfo();

            updateInfo.FileName = "UpdateFile.zip";
            updateInfo.CurrentVersion = new System.Version("0.9.0.0");
            updateInfo.NewVersion = new System.Version("0.9.0.0");
            updateInfo.RemoteUrl = "http://localhost:1016/Test/";
            updateInfo.UnpackPath = "./";
            updateInfo.TempPath = Utility.GetTempDirectory() + "\\";
            updateInfo.FileMd5 = "d43fb08b054d410019de18363be157d1";
            updateInfo.FileSize = 0;

            Updater updater = new Updater(updateInfo);
            updater.UpdatePlatform();


            #endregion

            Console.Read();

            #region 其他窗体测试

            //Application.EnableVisualStyles();
            //Application.SetCompatibleTextRenderingDefault(false);
            //Application.Run(new TestCustomDataGridViewForm());
            //Application.Run(new TestDataGridViewForm());
            //Application.Run(new TestDgvPageForm());
            //Application.Run(new PrintForm());       //打印机打印测试

            #endregion
        }

        //const int SM_TABLETPC = 86;
        //const int SM_DIGITIZER = 94;
        //const int SM_MAXIMUMTOUCHES = 95;
        //[DllImport("user32")]
        //static extern int GetSystemMetrics(int n);
    }
}















